using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

namespace fuzhu
{
    /// <summary>
    /// 日期选择窗体
    /// </summary>
    public partial class DateSelectionForm : Form
    {
        public DateTime SelectedDate { get; private set; }

        public DateSelectionForm()
        {
            InitializeComponent();
            this.SelectedDate = DateTime.Now;
        }

        public DateSelectionForm(DateTime defaultDate)
        {
            InitializeComponent();
            this.SelectedDate = defaultDate;
            this.dateTimePicker1.Value = defaultDate;
        }

        private void InitializeComponent()
        {
            this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
            this.btnOK = new System.Windows.Forms.Button();
            this.btnCancel = new System.Windows.Forms.Button();
            this.label1 = new System.Windows.Forms.Label();
            this.textBoxColumns = new System.Windows.Forms.TextBox();
            this.SuspendLayout();
            // 
            // dateTimePicker1
            // 
            this.dateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Short;
            this.dateTimePicker1.Location = new System.Drawing.Point(120, 30);
            this.dateTimePicker1.Name = "dateTimePicker1";
            this.dateTimePicker1.Size = new System.Drawing.Size(150, 25);
            this.dateTimePicker1.TabIndex = 0;
            // 
            // btnOK
            // 
            this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.btnOK.Location = new System.Drawing.Point(114, 103);
            this.btnOK.Name = "btnOK";
            this.btnOK.Size = new System.Drawing.Size(75, 30);
            this.btnOK.TabIndex = 1;
            this.btnOK.Text = "确定";
            this.btnOK.UseVisualStyleBackColor = true;
            this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
            // 
            // btnCancel
            // 
            this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.btnCancel.Location = new System.Drawing.Point(204, 103);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new System.Drawing.Size(75, 30);
            this.btnCancel.TabIndex = 2;
            this.btnCancel.Text = "取消";
            this.btnCancel.UseVisualStyleBackColor = true;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(30, 35);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(90, 15);
            this.label1.TabIndex = 3;
            this.label1.Text = "请选择日期:";
            // 
            // textBoxColumns
            // 
            this.textBoxColumns.Location = new System.Drawing.Point(33, 154);
            this.textBoxColumns.Multiline = true;
            this.textBoxColumns.Name = "textBoxColumns";
            this.textBoxColumns.ReadOnly = true;
            this.textBoxColumns.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
            this.textBoxColumns.Size = new System.Drawing.Size(450, 100);
            this.textBoxColumns.TabIndex = 4;
            this.textBoxColumns.Visible = false;
            // 
            // DateSelectionForm
            // 
            this.AcceptButton = this.btnOK;
            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.CancelButton = this.btnCancel;
            this.ClientSize = new System.Drawing.Size(510, 157);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.btnCancel);
            this.Controls.Add(this.btnOK);
            this.Controls.Add(this.dateTimePicker1);
            this.Controls.Add(this.textBoxColumns);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "DateSelectionForm";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
            this.Text = "选择发货日期";
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        private System.Windows.Forms.DateTimePicker dateTimePicker1;
        private System.Windows.Forms.Button btnOK;
        private System.Windows.Forms.Button btnCancel;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.TextBox textBoxColumns;

        /// <summary>
        /// 设置列信息
        /// </summary>
        /// <param name="columnInfo">列信息</param>
        public void SetColumnInfo(string columnInfo)
        {
            if (this.textBoxColumns != null)
            {
                this.textBoxColumns.Text = columnInfo;
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            this.SelectedDate = this.dateTimePicker1.Value.Date;
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}